package com.ruoyi.zhmk.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhmk.domain.ZhmkCarinoutInfo;
import com.ruoyi.zhmk.service.IZhmkCarinoutInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆进出记录Controller
 * 
 * @author ruoyi
 * @date 2021-06-24
 */
@RestController
@RequestMapping("/zhmk/carInfo")
public class ZhmkCarinoutInfoController extends BaseController
{
    @Autowired
    private IZhmkCarinoutInfoService zhmkCarinoutInfoService;

    /**
     * 查询车辆进出记录列表
     */
    @PreAuthorize("@ss.hasPermi('zhmk:carInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhmkCarinoutInfo zhmkCarinoutInfo)
    {
        startPage();
        List<ZhmkCarinoutInfo> list = zhmkCarinoutInfoService.selectZhmkCarinoutInfoList(zhmkCarinoutInfo);
        return getDataTable(list);
    }

    /**
     * 导出车辆进出记录列表
     */
    @PreAuthorize("@ss.hasPermi('zhmk:carInfo:export')")
    @Log(title = "车辆进出记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZhmkCarinoutInfo zhmkCarinoutInfo)
    {
        List<ZhmkCarinoutInfo> list = zhmkCarinoutInfoService.selectZhmkCarinoutInfoList(zhmkCarinoutInfo);
        ExcelUtil<ZhmkCarinoutInfo> util = new ExcelUtil<ZhmkCarinoutInfo>(ZhmkCarinoutInfo.class);
        return util.exportExcel(list, "车辆进出记录数据");
    }

    /**
     * 获取车辆进出记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('zhmk:carInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zhmkCarinoutInfoService.selectZhmkCarinoutInfoById(id));
    }

    /**
     * 新增车辆进出记录
     */
    @PreAuthorize("@ss.hasPermi('zhmk:carInfo:add')")
    @Log(title = "车辆进出记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhmkCarinoutInfo zhmkCarinoutInfo)
    {
        return toAjax(zhmkCarinoutInfoService.insertZhmkCarinoutInfo(zhmkCarinoutInfo));
    }

    /**
     * 修改车辆进出记录
     */
    @PreAuthorize("@ss.hasPermi('zhmk:carInfo:edit')")
    @Log(title = "车辆进出记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhmkCarinoutInfo zhmkCarinoutInfo)
    {
        return toAjax(zhmkCarinoutInfoService.updateZhmkCarinoutInfo(zhmkCarinoutInfo));
    }

    /**
     * 删除车辆进出记录
     */
    @PreAuthorize("@ss.hasPermi('zhmk:carInfo:remove')")
    @Log(title = "车辆进出记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zhmkCarinoutInfoService.deleteZhmkCarinoutInfoByIds(ids));
    }
}
